From : Ted Bailey (Ted@blitzuk.demon.co.uk)
Subject : Sprites in a display
> Good points, but yes to both. However, I did forget to mention that
> the copper list also uses a DisplayAdjust. I can't get two 32x32
> pixel 16 colour sprites to work with it either (only 1).
The attached example uses a 32 colour smoothscrolling 288*256 coplist.
It changes the palette, has two 32*32 pixel 16 colour sprites and it
seems to work fine for me (running on A1200).
ThinDisp.lha - a stunning new ECS/AGA demo by Ted... hmmm...
;Attached source follows
;! TO RUN THIS CORRECTLY, PLEASE REMEBER TO RAISE THE 'OBJECT-MAXIMUMS'
; IN THE COMPILER OPTIONS !
;
;
; An ECS Display example to help 'The Crow' - Ted Bailey 28/4/96
;
For pl=0 To 5 ; initialise six 32 colour
InitPalette pl,32 ; palettes
Next ;
BitMap 0,384,288,5 ; 32 col bitmap for background
BitMap 1,32,32,4 ; 16 col sprites bitmap
InitCopList 0,40,256,$0015,8,32,0 ; thin display (288*256), 16
DisplayAdjust 0,-4,8,-8,16,-16 ; pixels chopped off each side
VWait 50:BLITZ
Gosub initcolors ; init all six 32 col palettes
Gosub makesprite ; init 2 32*32 16 col sprites
Gosub colour_bmp ; draw random lines/circles
CreateDisplay 0:DisplayPalette 0,0
p=0:pl=0 ; init palette counters
Repeat
VWait
DisplayBitMap 0,0,x,y
;
Gosub movesprits ; bounce and display two
DisplaySprite 0,0,sx1,sy1,0 ; 32*32 16 colour sprites
DisplaySprite 0,1,sx2,sy2,4 ;
;
DisplayPalette 0,pl ;
p=QWrap(p+0.025,0,6) ; change palette
pl=Int(p) ;
;
x=16-Sin(ang)*16 ;
y=16-Cos(ang)*16 ; move bitmap in a circle
ang+0.05 ;
Until Joyb(0)
End
.initcolors
For pl=0 To 5
;
For n=1 To 15 ;
r=3+Rnd(12) ; colour registers 1-15
g=3+Rnd(12) ; will be random
b=3+Rnd(12) ;
PalRGB pl,n,r,g,b
Next
;
For n=1 To 15 ;
Select pl ; sprite colour registers
Case 0 ; are 16-31 and are shades
r=n:g=0:b=0 ; of one colour so they
Case 1 ; stand out against the
r=0:g=n:b=0 ; scrolling bitmap
Case 2 ;
r=0:g=0:b=n ;
Case 3 ; register 0 is black
r=n:g=n:b=0 ;
Case 4 ; register 16 is transparent
r=n:g=0:b=n ;
Case 5
r=0:g=n:b=n
End Select
PalRGB pl,16+n,r,g,b
Next
;
Next
Return
.makesprite
Use BitMap 1 ; use the 16 colour sprites bitmap
;
For n=1 To 15 ;
Circlef 16,16,16-n,n ; sprite 0 is a 16 colour 32*32
Next ; ball
GetaShape 0,0,0,32,32 ;
GetaSprite 0,0 ;
;
xv1=1+Rnd(3):yv1=1 ; sprite 0 x and y velocity
sx1=100+Rnd(100):sy1=-50 ; sprite 0 x and y screen position
;
For n=1 To 15 ;
Boxf n,n,32-n,32-n,n ; sprite 1 is a 16 colour 32*32
Next ; square
GetaShape 0,0,0,32,32 ;
GetaSprite 1,0 ;
;
xv2=1+Rnd(3):yv2=1 ; sprite 1 x and y velocity
sx2=100+Rnd(100):sy2=-50 ; sprite 1 x and y screen position
Return
.colour_bmp
Use BitMap 0 ; use the 32 colour bitmap
;
For n=1 To 15
cl=Int(n+Rnd(7)) ; choose colours between 1->22, but
If cl=16 Then cl=15 ; not 16 (transparent)
;
Circlef Rnd(384),Rnd(288),Rnd(70),cl
Line Rnd(384),Rnd(288),Rnd(384),Rnd(288),cl
Next
Return
.movesprits
sx1+xv1 ;
If sx1<16 Then xv1=-xv1:sx1=16:sv1=-1 ; bounce of walls
If sx1>272 Then xv1=-xv1:sx1=272:sv1=1 ;
;
yv1+1 ;
sy1+yv1 ; bounce of ground
If sy1>230 Then yv1=-10-Rnd(12):sy1=230 ;
;
sx2+xv2 ;
If sx2<16 Then xv2=-xv2:sx2=16:sv2=-1 ; "
If sx2>272 Then xv2=-xv2:sx2=272:sv2=1 ;
;
yv2+1 ;
sy2+yv2 ; "
If sy2>230 Then yv2=-10-Rnd(12):sy2=230 ;
Return